//
//  KFDSettingsManager.h
//  KFD
//
//  Created by JIRENTIANXIANG on 7/9/15.
//  Copyright © 2015 kfd. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "KFDClient.h"
#import "KFDMessageNotificationSettings.h"

@interface KFDSettingsManager : NSObject

@property (strong,nonatomic) KFDAlarmRingtoneSettings* alarmRingtoneSettings;
//@property (strong,nonatomic) KFDAlarmSettings* alarmSettings;
@property (strong,nonatomic) NSMutableDictionary* alarmSettingsOfAllTypes;
@property (strong,nonatomic) KFDAuxiliaryFunctionSettings* auxiliaryFunctionSettings;
@property (strong,nonatomic) KFDMessageNotificationSettings* messageNotificationSettings;

+(KFDSettingsManager*)sharedManager;
//-(BOOL)loadSettingsForCurrentAccount;
//-(BOOL)loadSettingsForAccount:(NSString*)phoneNumber;
//-(void)saveSettingsForCurrentAccount;

-(NSURLSessionTask*)getAuxiliaryFunctionSettingsWithSuccessHandler:(KFDGetAuxiliaryFunctionSettingsSuccessHanler)successHandler failureHandler:(KFDRequestFailureHandler)failureHandler;

-(NSURLSessionTask*)updateAuxiliaryFunctionSettingsWithSuccessHandler:(KFDUpdateAuxiliaryFunctionSettingsSuccessHandler)successHandler failureHandler:(KFDRequestFailureHandler)failureHandler;

-(NSURLSessionTask*)getAlarmSettingsWithType:(NSString*)type successHandler:(KFDGetAlarmSettingsSuccessHandler)successHandler failureHandler:(KFDRequestFailureHandler)failureHandler;

-(NSURLSessionTask*)updateAlarmSettingsWithType:(NSString*)type successHandler:(KFDUpdateAlarmSettingsSuccessHandler)successHandler failureHandler:(KFDRequestFailureHandler)failureHandler;

-(NSURLSessionTask*)getAlarmRingtoneSettingsWithSuccessHandler:(KFDGetAlarmRingtoneSettingsSuccessHandler)successHandler failureHandler:(KFDRequestFailureHandler)failureHandler;

-(NSURLSessionTask*)updateAlarmRingtoneSettingsWithSuccessHandler:(KFDUpdateAlarmRingtoneSettingsSuccessHandler)successHandler failureHandler:(KFDRequestFailureHandler)failureHandler;

-(void)saveMessageNotificationSettings; //save to local storage
-(void)loadMessageNotificationSettings; //load from local storage

@end

//-----------------------------------------------------------------------------------------

typedef void(^KFDSettingsManagerIllegalInputHandler)(NSString* message);

@interface KFDSettingsManager (BusinessRules)

-(BOOL)checkAlarmBaseValue:(NSString *)baseValue floatValue:(NSString *)floatValue illegalInputHandler:(KFDSettingsManagerIllegalInputHandler)handler;

-(BOOL)checkMinValue:(NSString *)minValue maxValue:(NSString *)maxValue illegalInputHandler:(KFDSettingsManagerIllegalInputHandler)handler;

@end
